﻿
'
'This work is licensed under Creative commons - BY
'By: Tim Anthony Manuel (Brightknight)
'Contact: timanth(at)gmail.com
'

Public Class frmMain

    Private OperationCollection As New Collection 'will be used to hold the operations
    Private CopyFileQueue As New Collection 'will be used to hold all file operations

    Private Sub frmMain_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
        'check first if there are running operations. if so, ask the user and inform the user about the consequences
        If OperationCollection.Count > 0 Then
            If MessageBox.Show("There are on-going copying operations. Please be reminded" & vbCrLf _
                          & "that exiting while operations are going on can result to" & vbCrLf _
                          & "corrupt data and probably, a lot of headaches. If you can" & vbCrLf _
                          & "wait a little more, then kindly wait." & vbCrLf & vbCrLf _
                          & "Are you sure you want to exit now?", "Oops, operations on the move", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) = Windows.Forms.DialogResult.Yes Then
            Else
                e.Cancel = True
            End If

        End If
    End Sub

    Private Sub frmMain_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        'do the initializations here
        Try
            GetUISettings(Me.BackColor, "uibackgroud", MTSettingType.MT_color)
        Catch ex As Exception

        End Try

    End Sub

    Private Sub AboutToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AboutToolStripMenuItem.Click
        frmAbout.ShowDialog()
    End Sub

    Private Sub PreferencesToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PreferencesToolStripMenuItem.Click
        frmPreferences.ShowDialog()
    End Sub

    Private Sub btnAddNew_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAddNew.Click
        If frmCopyWizard.ShowDialog() = Windows.Forms.DialogResult.OK Then

            'better make a collection to handle all the panels so that it will be a little cleaner and easier to maintain.
            'then later on, you may add the panels in the collection to the tab

            'evaluate the number of files and directories

            'draw a panel to contain the operation status
            '//dummy panel only
            Dim mpanel As New Panel
            Dim mlabel1 As New Label
            mlabel1.Text = "Dummy panel only for testing"
            mlabel1.Location = New Point(40, 20)

            With mpanel
                .Size = New Size(tabStatus.TabPages("tabOperation").Width - 20, 100)
                .Location = New Point(10, (tabStatus.TabPages("tabOperation").Controls.Count * 105) + 10)
                .BackColor = Color.Gray
                .Controls.Add(mlabel1)
            End With

            'add controls to the panel like labels, buttons, etc

            'add the panel to the tab
            tabStatus.TabPages("tabOperation").Controls.Add(mpanel)

            'add the file/path to be copied into the collection
            Dim CopyList(5) As String
            CopyList(0) = frmCopyWizard.SourceName
            CopyList(1) = (frmCopyWizard.DestString & "\" & IO.Path.GetFileName(frmCopyWizard.SourceName)).Replace("\\", "\")


            'perform the copy. better make a new thread for each copy operations so as not to interfere with the UI function
            Try
                IO.File.Copy(CopyList(0), CopyList(1))

            Catch ex As Exception

            End Try
        Else

        End If

    End Sub



    Private Sub BackgroundWorker4_DoWork(ByVal sender As System.Object, ByVal e As System.ComponentModel.DoWorkEventArgs) Handles BackgroundWorker4.DoWork

    End Sub
    Private Sub BackgroundWorker3_DoWork(ByVal sender As System.Object, ByVal e As System.ComponentModel.DoWorkEventArgs) Handles BackgroundWorker3.DoWork

    End Sub
    Private Sub BackgroundWorker2_DoWork(ByVal sender As System.Object, ByVal e As System.ComponentModel.DoWorkEventArgs) Handles BackgroundWorker2.DoWork

    End Sub
    Private Sub BackgroundWorker1_DoWork(ByVal sender As System.Object, ByVal e As System.ComponentModel.DoWorkEventArgs) Handles BackgroundWorker1.DoWork

    End Sub

    Private Sub BackgroundWorker4_ProgressChanged(ByVal sender As Object, ByVal e As System.ComponentModel.ProgressChangedEventArgs) Handles BackgroundWorker4.ProgressChanged

    End Sub

    Private Sub BackgroundWorker3_ProgressChanged(ByVal sender As Object, ByVal e As System.ComponentModel.ProgressChangedEventArgs) Handles BackgroundWorker3.ProgressChanged

    End Sub

    Private Sub BackgroundWorker2_ProgressChanged(ByVal sender As Object, ByVal e As System.ComponentModel.ProgressChangedEventArgs) Handles BackgroundWorker2.ProgressChanged

    End Sub

    Private Sub BackgroundWorker1_ProgressChanged(ByVal sender As Object, ByVal e As System.ComponentModel.ProgressChangedEventArgs) Handles BackgroundWorker1.ProgressChanged

    End Sub


    Private Sub BackgroundWorker4_RunWorkerCompleted(ByVal sender As Object, ByVal e As System.ComponentModel.RunWorkerCompletedEventArgs) Handles BackgroundWorker4.RunWorkerCompleted

    End Sub

    Private Sub BackgroundWorker3_RunWorkerCompleted(ByVal sender As Object, ByVal e As System.ComponentModel.RunWorkerCompletedEventArgs) Handles BackgroundWorker3.RunWorkerCompleted

    End Sub

    Private Sub BackgroundWorker2_RunWorkerCompleted(ByVal sender As Object, ByVal e As System.ComponentModel.RunWorkerCompletedEventArgs) Handles BackgroundWorker2.RunWorkerCompleted

    End Sub

    Private Sub BackgroundWorker1_RunWorkerCompleted(ByVal sender As Object, ByVal e As System.ComponentModel.RunWorkerCompletedEventArgs) Handles BackgroundWorker1.RunWorkerCompleted

    End Sub


End Class
